namespace pos.entity
{
using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.Data.OleDb;
using System.Collections;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Criterion;
/// <summary>
/// t_hreturned 的摘要说明
/// </summary>
public class t_hreturned:IEntityUtil
{
//   结算状态值的哈希表 
	private static Hashtable m_enum_settleState;
	public static Hashtable  enum_settleState
	{
		get{return m_enum_settleState;}
	}
	public const int SETTLEYES=1;
	public const int SETTLENO=0;
	//   列名称哈希表 
	private static Hashtable m_colLabels;    	 
	public static Hashtable colLabels//
	{
		get{return m_colLabels;}
	}
	//表字段名称哈希表
	private static ArrayList m_colNames;     
	public static ArrayList  colNames　
	{
		get{return m_colNames;}
	}
	private Hreturned __hreturned;
	public long seqID  
	{
		get{return __hreturned.seqID;}
		set{ __hreturned.seqID=value;}
	}
	public long commoditySeqID  
	{
		get{return __hreturned.commoditySeqID;}
		set{ __hreturned.commoditySeqID=value;}
	}
	public String commodityID  
	{
		get{return __hreturned.commodityID;}
		set{ __hreturned.commodityID=value;}
	}
	public String commodityName  
	{
		get{return __hreturned.commodityName;}
		set{ __hreturned.commodityName=value;}
	}
	public double returnedAmount  
	{
		get{return __hreturned.returnedAmount;}
		set{ __hreturned.returnedAmount=value;}
	}
	public double returnedMoney  
	{
		get{return __hreturned.returnedMoney;}
		set{ __hreturned.returnedMoney=value;}
	}
	public double returnedPrice  
	{
		get{return __hreturned.returnedPrice;}
		set{ __hreturned.returnedPrice=value;}
	}
	public double sReturnedMoney  
	{
		get{return __hreturned.sReturnedMoney;}
		set{ __hreturned.sReturnedMoney=value;}
	}
	public double sReturnedPrice  
	{
		get{return __hreturned.sReturnedPrice;}
		set{ __hreturned.sReturnedPrice=value;}
	}
	public String userID  
	{
		get{return __hreturned.userID;}
		set{ __hreturned.userID=value;}
	}
	public DateTime returnedTime  
	{
		get{return __hreturned.returnedTime;}
		set{ __hreturned.returnedTime=value;}
	}
	public String remark  
	{
		get{return __hreturned.remark;}
		set{ __hreturned.remark=value;}
	}
	public double lossMoney  
	{
		get{return __hreturned.lossMoney;}
		set{ __hreturned.lossMoney=value;}
	}
	public int settleState  
	{
		get{return __hreturned.settleState;}
		set{ __hreturned.settleState=value;}
	}
	private static  HreturnedDao dao=(HreturnedDao)SpringContext.Context.GetObject("HreturnedDao");
	public static HreturnedDao DAO
	{
		get{return dao;}
		
	}
	
	public t_hreturned()
	{
		__hreturned=new Hreturned();
	  	seqID=consts.long_min;
	  	commoditySeqID=consts.long_min;
	  	commodityID="";
	  	commodityName="";
	  	returnedAmount=consts.double_min;
	  	returnedMoney=consts.double_min;
	  	returnedPrice=consts.double_min;
	  	sReturnedMoney=consts.double_min;
	  	sReturnedPrice=consts.double_min;
	  	userID="";
	  	returnedTime=DateTime.Now;
	  	remark="";
	  	lossMoney=0;
	  	settleState=0;
	  // dao=(HreturnedDao)SpringContext.Context.GetObject("HreturnedDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("commoditySeqID", @"商品序号");
		colNames.Add("commoditySeqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("returnedAmount", @"退货数量");
		colNames.Add("returnedAmount");
		m_colLabels.Add("returnedMoney", @"应退金额");
		colNames.Add("returnedMoney");
		m_colLabels.Add("returnedPrice", @"应退价格");
		colNames.Add("returnedPrice");
		m_colLabels.Add("sReturnedMoney", @"实退金额");
		colNames.Add("sReturnedMoney");
		m_colLabels.Add("sReturnedPrice", @"实退价格");
		colNames.Add("sReturnedPrice");
		m_colLabels.Add("userID", @"退货人");
		colNames.Add("userID");
		m_colLabels.Add("returnedTime", @"退货时间");
		colNames.Add("returnedTime");
		m_colLabels.Add("remark", @"退货说明");
		colNames.Add("remark");
		m_colLabels.Add("lossMoney", @"损耗金额");
		colNames.Add("lossMoney");
		m_colLabels.Add("settleState", @"结算状态");
		colNames.Add("settleState");
		m_enum_settleState= new Hashtable();
		m_enum_settleState.Add("1", @"已结算");
		m_enum_settleState.Add("0", @"未结算");
	  }
	
	}
	public t_hreturned(Hreturned entity )
	{
		__hreturned=entity;
		
	  // dao=(HreturnedDao)SpringContext.Context.GetObject("HreturnedDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("commoditySeqID", @"商品序号");
		colNames.Add("commoditySeqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("returnedAmount", @"退货数量");
		colNames.Add("returnedAmount");
		m_colLabels.Add("returnedMoney", @"应退金额");
		colNames.Add("returnedMoney");
		m_colLabels.Add("returnedPrice", @"应退价格");
		colNames.Add("returnedPrice");
		m_colLabels.Add("sReturnedMoney", @"实退金额");
		colNames.Add("sReturnedMoney");
		m_colLabels.Add("sReturnedPrice", @"实退价格");
		colNames.Add("sReturnedPrice");
		m_colLabels.Add("userID", @"退货人");
		colNames.Add("userID");
		m_colLabels.Add("returnedTime", @"退货时间");
		colNames.Add("returnedTime");
		m_colLabels.Add("remark", @"退货说明");
		colNames.Add("remark");
		m_colLabels.Add("lossMoney", @"损耗金额");
		colNames.Add("lossMoney");
		m_colLabels.Add("settleState", @"结算状态");
		colNames.Add("settleState");
		m_enum_settleState= new Hashtable();
		m_enum_settleState.Add("1", @"已结算");
		m_enum_settleState.Add("0", @"未结算");
	  }
	
	}
	public Object uniqueResult(DetachedCriteria dc)
    {
        return dao.uniqueResult(dc);
    }
	 public DetachedCriteria DC 
     {
        	get{return DetachedCriteria.For(typeof(Hreturned));}
     }
	public const string ENTITYNAME="t_hreturned";
	public const int SEQN0=831;
	
    public void checkAdd()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	//try{Convert.ToInt64(commoditySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	commoditySeqID<consts.long_min+1)
			throw (new Exception("请输入商品序号"));

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品名称不能为空!"));	
	

	//try{Convert.ToDouble(returnedAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedAmount<consts.double_min+1)
			throw (new Exception("请输入退货数量"));
		if(returnedAmount>0)
			returnedAmount+=0.000001;
		if(returnedAmount<0)
			returnedAmount-=0.000001;
		
			if(((long)((returnedAmount)*100 ))*10!=(long)((returnedAmount)*1000) )
				throw (new Exception("退货数量小数精度不能大于2位returnedAmount="+returnedAmount.ToString()));
		if(returnedAmount>0)
			returnedAmount-=0.000001;
		if(returnedAmount<0)
			returnedAmount+=0.000001;
	

	//try{Convert.ToDouble(returnedMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedMoney<consts.double_min+1)
			throw (new Exception("请输入应退金额"));
		if(returnedMoney>0)
			returnedMoney+=0.000001;
		if(returnedMoney<0)
			returnedMoney-=0.000001;
		
			if(((long)((returnedMoney)*100 ))*10!=(long)((returnedMoney)*1000) )
				throw (new Exception("应退金额小数精度不能大于2位returnedMoney="+returnedMoney.ToString()));
		if(returnedMoney>0)
			returnedMoney-=0.000001;
		if(returnedMoney<0)
			returnedMoney+=0.000001;
	

	//try{Convert.ToDouble(returnedPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedPrice<consts.double_min+1)
			throw (new Exception("请输入应退价格"));
		if(returnedPrice>0)
			returnedPrice+=0.000001;
		if(returnedPrice<0)
			returnedPrice-=0.000001;
		
			if(((long)((returnedPrice)*100 ))*10!=(long)((returnedPrice)*1000) )
				throw (new Exception("应退价格小数精度不能大于2位returnedPrice="+returnedPrice.ToString()));
		if(returnedPrice>0)
			returnedPrice-=0.000001;
		if(returnedPrice<0)
			returnedPrice+=0.000001;
	

	//try{Convert.ToDouble(sReturnedMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	sReturnedMoney<consts.double_min+1)
			throw (new Exception("请输入实退金额"));
		if(sReturnedMoney>0)
			sReturnedMoney+=0.000001;
		if(sReturnedMoney<0)
			sReturnedMoney-=0.000001;
		
			if(((long)((sReturnedMoney)*100 ))*10!=(long)((sReturnedMoney)*1000) )
				throw (new Exception("实退金额小数精度不能大于2位sReturnedMoney="+sReturnedMoney.ToString()));
		if(sReturnedMoney>0)
			sReturnedMoney-=0.000001;
		if(sReturnedMoney<0)
			sReturnedMoney+=0.000001;
	

	//try{Convert.ToDouble(sReturnedPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	sReturnedPrice<consts.double_min+1)
			throw (new Exception("请输入实退价格"));
		if(sReturnedPrice>0)
			sReturnedPrice+=0.000001;
		if(sReturnedPrice<0)
			sReturnedPrice-=0.000001;
		
			if(((long)((sReturnedPrice)*100 ))*10!=(long)((sReturnedPrice)*1000) )
				throw (new Exception("实退价格小数精度不能大于2位sReturnedPrice="+sReturnedPrice.ToString()));
		if(sReturnedPrice>0)
			sReturnedPrice-=0.000001;
		if(sReturnedPrice<0)
			sReturnedPrice+=0.000001;
	

	
	len=userID.Trim().Length;
	if(len>20)
		 throw (new Exception("退货人字符长度最长不能超过20,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("退货人不能为空!"));	
	

	//try{Convert.ToDateTime(returnedTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	returnedTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入退货时间"));

	
	len=remark.Trim().Length;
	if(len>50)
		 throw (new Exception("退货说明字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDouble(lossMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	lossMoney<consts.double_min+1)
			throw (new Exception("请输入损耗金额"));
		if(lossMoney>0)
			lossMoney+=0.000001;
		if(lossMoney<0)
			lossMoney-=0.000001;
		
			if(((long)((lossMoney)*100 ))*10!=(long)((lossMoney)*1000) )
				throw (new Exception("损耗金额小数精度不能大于2位lossMoney="+lossMoney.ToString()));
		if(lossMoney>0)
			lossMoney-=0.000001;
		if(lossMoney<0)
			lossMoney+=0.000001;
	

	//try{Convert.ToInt32(settleState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	settleState<consts.int_min+1)
			throw (new Exception("请输入结算状态"));

//unique="yes" 唯一性验证
    }
    public void checkUpdate()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	//try{Convert.ToInt64(commoditySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	commoditySeqID<consts.long_min+1)
			throw (new Exception("请输入商品序号"));

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品名称不能为空!"));	
	

	//try{Convert.ToDouble(returnedAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedAmount<consts.double_min+1)
			throw (new Exception("请输入退货数量"));
		if(returnedAmount>0)
			returnedAmount+=0.000001;
		if(returnedAmount<0)
			returnedAmount-=0.000001;
		
			if(((long)((returnedAmount)*100 ))*10!=(long)((returnedAmount)*1000) )
				throw (new Exception("退货数量小数精度不能大于2位returnedAmount="+returnedAmount.ToString()));
		if(returnedAmount>0)
			returnedAmount-=0.000001;
		if(returnedAmount<0)
			returnedAmount+=0.000001;
	

	//try{Convert.ToDouble(returnedMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedMoney<consts.double_min+1)
			throw (new Exception("请输入应退金额"));
		if(returnedMoney>0)
			returnedMoney+=0.000001;
		if(returnedMoney<0)
			returnedMoney-=0.000001;
		
			if(((long)((returnedMoney)*100 ))*10!=(long)((returnedMoney)*1000) )
				throw (new Exception("应退金额小数精度不能大于2位returnedMoney="+returnedMoney.ToString()));
		if(returnedMoney>0)
			returnedMoney-=0.000001;
		if(returnedMoney<0)
			returnedMoney+=0.000001;
	

	//try{Convert.ToDouble(returnedPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	returnedPrice<consts.double_min+1)
			throw (new Exception("请输入应退价格"));
		if(returnedPrice>0)
			returnedPrice+=0.000001;
		if(returnedPrice<0)
			returnedPrice-=0.000001;
		
			if(((long)((returnedPrice)*100 ))*10!=(long)((returnedPrice)*1000) )
				throw (new Exception("应退价格小数精度不能大于2位returnedPrice="+returnedPrice.ToString()));
		if(returnedPrice>0)
			returnedPrice-=0.000001;
		if(returnedPrice<0)
			returnedPrice+=0.000001;
	

	//try{Convert.ToDouble(sReturnedMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	sReturnedMoney<consts.double_min+1)
			throw (new Exception("请输入实退金额"));
		if(sReturnedMoney>0)
			sReturnedMoney+=0.000001;
		if(sReturnedMoney<0)
			sReturnedMoney-=0.000001;
		
			if(((long)((sReturnedMoney)*100 ))*10!=(long)((sReturnedMoney)*1000) )
				throw (new Exception("实退金额小数精度不能大于2位sReturnedMoney="+sReturnedMoney.ToString()));
		if(sReturnedMoney>0)
			sReturnedMoney-=0.000001;
		if(sReturnedMoney<0)
			sReturnedMoney+=0.000001;
	

	//try{Convert.ToDouble(sReturnedPrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	sReturnedPrice<consts.double_min+1)
			throw (new Exception("请输入实退价格"));
		if(sReturnedPrice>0)
			sReturnedPrice+=0.000001;
		if(sReturnedPrice<0)
			sReturnedPrice-=0.000001;
		
			if(((long)((sReturnedPrice)*100 ))*10!=(long)((sReturnedPrice)*1000) )
				throw (new Exception("实退价格小数精度不能大于2位sReturnedPrice="+sReturnedPrice.ToString()));
		if(sReturnedPrice>0)
			sReturnedPrice-=0.000001;
		if(sReturnedPrice<0)
			sReturnedPrice+=0.000001;
	

	
	len=userID.Trim().Length;
	if(len>20)
		 throw (new Exception("退货人字符长度最长不能超过20,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("退货人不能为空!"));	
	

	//try{Convert.ToDateTime(returnedTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	returnedTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入退货时间"));

	
	len=remark.Trim().Length;
	if(len>50)
		 throw (new Exception("退货说明字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDouble(lossMoney);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	lossMoney<consts.double_min+1)
			throw (new Exception("请输入损耗金额"));
		if(lossMoney>0)
			lossMoney+=0.000001;
		if(lossMoney<0)
			lossMoney-=0.000001;
		
			if(((long)((lossMoney)*100 ))*10!=(long)((lossMoney)*1000) )
				throw (new Exception("损耗金额小数精度不能大于2位lossMoney="+lossMoney.ToString()));
		if(lossMoney>0)
			lossMoney-=0.000001;
		if(lossMoney<0)
			lossMoney+=0.000001;
	

	//try{Convert.ToInt32(settleState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	settleState<consts.int_min+1)
			throw (new Exception("请输入结算状态"));

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("seqID", seqID);
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==1)
			return;
		if(list.Count==0)
			throw (new Exception("该记录已经被删除"));	
		else
			throw (new Exception("改纪录出现重名!"));
    }
    public void add()
    {
        try
        {
            checkAdd();
         	dao.Add(__hreturned);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void delByseqID()
    {
    
        try
        {
          dao.Delete(__hreturned);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }

    public  void update()
    {
        try
        {
            checkUpdate();
            dao.Update(__hreturned);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void ExecDataUpdate(int rowNo)
    {
		if(m_updateRow==null)
			return;
		int ii=0;
m_updateRow(rowNo,ii++,				(				  string.Format("{0}",seqID)				  ));	
m_updateRow(rowNo,ii++,commodityID);	
m_updateRow(rowNo,ii++,commodityName);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",returnedPrice)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",sReturnedMoney)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",sReturnedPrice)/***/)
);	
m_updateRow(rowNo,ii++,			returnedTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",returnedTime));	
m_updateRow(rowNo,ii++,remark);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",lossMoney)/***/)
);	

    }
    public void ExecHeadInsert()
    {
		if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,50,"编号");
			m_insertHead(ii++,150,"商品条形码");
			m_insertHead(ii++,220,"商品名称");
			m_insertHead(ii++,80,"退货数量");
			m_insertHead(ii++,80,"应退金额");
			m_insertHead(ii++,80,"应退价格");
			m_insertHead(ii++,80,"实退金额");
			m_insertHead(ii++,80,"实退价格");
			m_insertHead(ii++,180,"退货时间");
			m_insertHead(ii++,250,"退货说明");
			m_insertHead(ii++,90,"损耗金额");
		}		
    }
    public void ExecDataInsert()
	{
		if(m_insertRow==null)
			return;
		int ii=0;
     	m_insertRow(0,ii++,				(				  string.Format("{0}",seqID)				  ));
     	m_insertRow(0,ii++,commodityID);
     	m_insertRow(0,ii++,commodityName);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",returnedPrice)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",sReturnedMoney)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",sReturnedPrice)/***/)
);
     	m_insertRow(0,ii++,			returnedTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",returnedTime));
     	m_insertRow(0,ii++,remark);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",lossMoney)/***/)
);
    }
    public void ExecDataInsertByQuery(DetachedCriteria dc)
    {
      
         IList list=dao.List(dc); 
        
        if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,50,"编号");
			m_insertHead(ii++,150,"商品条形码");
			m_insertHead(ii++,220,"商品名称");
			m_insertHead(ii++,80,"退货数量");
			m_insertHead(ii++,80,"应退金额");
			m_insertHead(ii++,80,"应退价格");
			m_insertHead(ii++,80,"实退金额");
			m_insertHead(ii++,80,"实退价格");
			m_insertHead(ii++,180,"退货时间");
			m_insertHead(ii++,250,"退货说明");
			m_insertHead(ii++,90,"损耗金额");
		}		
		
      if(m_insertRow!=null)
      {
        int j=0;
        foreach(Hreturned obj in list)			
        {
		  int ii=0;
	     
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.seqID)
				  )
);
m_insertRow(j,ii++,obj.commodityID.ToString());
m_insertRow(j,ii++,obj.commodityName.ToString());
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.returnedPrice)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.sReturnedMoney)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.sReturnedPrice)
					)
);
m_insertRow(j,ii++,			obj.returnedTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",obj.returnedTime)
);
m_insertRow(j,ii++,obj.remark.ToString());
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.lossMoney)
					)
);
		j++;
        }
        

	
       }
    }

    
    public IList List(DetachedCriteria dc)
    {
        try
        {
           
            return dao.List(dc);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
    
    public bool Init(DetachedCriteria dc)
    {
    
    		Hreturned obj=dao.Get(dc);
    		if(obj==null)
    			return false;
    		else
    		{
    			__hreturned=obj;
            	return true;
            }
        
    }
    public static t_hreturned Get(DetachedCriteria dc)
    {
    	
    	Hreturned obj=((HreturnedDao)SpringContext.Context.GetObject("HreturnedDao"))
	 	.Get(dc);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_hreturned( obj );
        
    }
	 public static t_hreturned GetBySeqID(long val)
	 {
	 	Hreturned obj=((HreturnedDao)SpringContext.Context.GetObject("HreturnedDao"))
	 	.GetBySeqID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_hreturned( obj );
	 	
	 	
	 }
	 public  bool InitBySeqID(long val)
	 {
	 	

	 	Hreturned obj=dao.GetBySeqID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__hreturned=obj;
	 		return true;
	 	}
	 	
	 	
	 }
    
       public bool showInForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			Controls["seqID"].Text=				(				  string.Format("{0}",seqID)				  );
		}
		if(Controls["commoditySeqID"]!=null)
		{
			Controls["commoditySeqID"].Text=				(				  string.Format("{0}",commoditySeqID)				  );
		}
		if(Controls["commodityID"]!=null)
		{
			Controls["commodityID"].Text=commodityID;
		}
		if(Controls["commodityName"]!=null)
		{
			Controls["commodityName"].Text=commodityName;
		}
		if(Controls["returnedAmount"]!=null)
		{
			Controls["returnedAmount"].Text=/***/(						string.Format("{0:F2}",returnedAmount)/***/)
;
		}
		if(Controls["returnedMoney"]!=null)
		{
			Controls["returnedMoney"].Text=/***/(						string.Format("{0:F2}",returnedMoney)/***/)
;
		}
		if(Controls["returnedPrice"]!=null)
		{
			Controls["returnedPrice"].Text=/***/(						string.Format("{0:F2}",returnedPrice)/***/)
;
		}
		if(Controls["sReturnedMoney"]!=null)
		{
			Controls["sReturnedMoney"].Text=/***/(						string.Format("{0:F2}",sReturnedMoney)/***/)
;
		}
		if(Controls["sReturnedPrice"]!=null)
		{
			Controls["sReturnedPrice"].Text=/***/(						string.Format("{0:F2}",sReturnedPrice)/***/)
;
		}
		if(Controls["userID"]!=null)
		{
			Controls["userID"].Text=userID;
		}
		if(Controls["returnedTime"]!=null)
		{
			Controls["returnedTime"].Text=			returnedTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",returnedTime);
		}
		if(Controls["remark"]!=null)
		{
			Controls["remark"].Text=remark;
		}
		if(Controls["lossMoney"]!=null)
		{
			Controls["lossMoney"].Text=/***/(						string.Format("{0:F2}",lossMoney)/***/)
;
		}
		if(Controls["settleState"]!=null)
		{
			Controls["settleState"].Text=	t_hreturned.enum_settleState[settleState.ToString()].ToString()
;
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    public  t_hreturned Init(Hreturned item)
    {
        __hreturned=item;
        return this;
    }

    
     public bool initByForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			
			if(Controls["seqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["seqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{seqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
			else
			{
				try{seqID=(Controls["seqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["seqID"].Text));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commoditySeqID"]!=null)
		{
			
			if(Controls["commoditySeqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commoditySeqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commoditySeqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["commoditySeqID"].Focus();
					throw  (new Exception("商品序号格式不正确！！"));
				}
				
			}
			else
			{
				try{commoditySeqID=(Controls["commoditySeqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["commoditySeqID"].Text));}
				catch
				{
					 Controls["commoditySeqID"].Focus();
					throw  (new Exception("商品序号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityID"]!=null)
		{
			
			if(Controls["commodityID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityID=v;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityID=Controls["commodityID"].Text;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityName"]!=null)
		{
			
			if(Controls["commodityName"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityName"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityName=v;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityName=Controls["commodityName"].Text;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedAmount"]!=null)
		{
			
			if(Controls["returnedAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedAmount"].Focus();
					throw  (new Exception("退货数量格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedAmount=(Controls["returnedAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedAmount"].Text));}
				catch
				{
					 Controls["returnedAmount"].Focus();
					throw  (new Exception("退货数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedMoney"]!=null)
		{
			
			if(Controls["returnedMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedMoney"].Focus();
					throw  (new Exception("应退金额格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedMoney=(Controls["returnedMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedMoney"].Text));}
				catch
				{
					 Controls["returnedMoney"].Focus();
					throw  (new Exception("应退金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedPrice"]!=null)
		{
			
			if(Controls["returnedPrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedPrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedPrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["returnedPrice"].Focus();
					throw  (new Exception("应退价格格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedPrice=(Controls["returnedPrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["returnedPrice"].Text));}
				catch
				{
					 Controls["returnedPrice"].Focus();
					throw  (new Exception("应退价格格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["sReturnedMoney"]!=null)
		{
			
			if(Controls["sReturnedMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["sReturnedMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{sReturnedMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["sReturnedMoney"].Focus();
					throw  (new Exception("实退金额格式不正确！！"));
				}
				
			}
			else
			{
				try{sReturnedMoney=(Controls["sReturnedMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["sReturnedMoney"].Text));}
				catch
				{
					 Controls["sReturnedMoney"].Focus();
					throw  (new Exception("实退金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["sReturnedPrice"]!=null)
		{
			
			if(Controls["sReturnedPrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["sReturnedPrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{sReturnedPrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["sReturnedPrice"].Focus();
					throw  (new Exception("实退价格格式不正确！！"));
				}
				
			}
			else
			{
				try{sReturnedPrice=(Controls["sReturnedPrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["sReturnedPrice"].Text));}
				catch
				{
					 Controls["sReturnedPrice"].Focus();
					throw  (new Exception("实退价格格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["userID"]!=null)
		{
			
			if(Controls["userID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["userID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{userID=v;}
				catch
				{
					 Controls["userID"].Focus();
					throw  (new Exception("退货人格式不正确！！"));
				}
				
			}
			else
			{
				try{userID=Controls["userID"].Text;}
				catch
				{
					 Controls["userID"].Focus();
					throw  (new Exception("退货人格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["returnedTime"]!=null)
		{
			
			if(Controls["returnedTime"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["returnedTime"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{returnedTime=(v==""?new DateTime(1000,1,1):Convert.ToDateTime(v));}
				catch
				{
					 Controls["returnedTime"].Focus();
					throw  (new Exception("退货时间格式不正确！！"));
				}
				
			}
			else
			{
				try{returnedTime=(Controls["returnedTime"].Text==""?new DateTime(1000,1,1):Convert.ToDateTime(Controls["returnedTime"].Text));}
				catch
				{
					 Controls["returnedTime"].Focus();
					throw  (new Exception("退货时间格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["remark"]!=null)
		{
			
			if(Controls["remark"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["remark"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{remark=v;}
				catch
				{
					 Controls["remark"].Focus();
					throw  (new Exception("退货说明格式不正确！！"));
				}
				
			}
			else
			{
				try{remark=Controls["remark"].Text;}
				catch
				{
					 Controls["remark"].Focus();
					throw  (new Exception("退货说明格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["lossMoney"]!=null)
		{
			
			if(Controls["lossMoney"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["lossMoney"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{lossMoney=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["lossMoney"].Focus();
					throw  (new Exception("损耗金额格式不正确！！"));
				}
				
			}
			else
			{
				try{lossMoney=(Controls["lossMoney"].Text==""?consts.double_min:Convert.ToDouble(Controls["lossMoney"].Text));}
				catch
				{
					 Controls["lossMoney"].Focus();
					throw  (new Exception("损耗金额格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["settleState"]!=null)
		{
			
			if(Controls["settleState"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["settleState"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{settleState=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["settleState"].Focus();
					throw  (new Exception("结算状态格式不正确！！"));
				}
				
			}
			else
			{
				try{settleState=(Controls["settleState"].Text==""?consts.int_min:Convert.ToInt32(Controls["settleState"].Text));}
				catch
				{
					 Controls["settleState"].Focus();
					throw  (new Exception("结算状态格式不正确！！"));
				}
				
			}
				
				
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    

}

}
